#include <iostream>
#include "stdafx.h"
#include "resource.h"

#include "Redirect.h"
#include "outputdlg.h"

BEGIN_MESSAGE_MAP( OutputDlg, CDialog )
END_MESSAGE_MAP()

OutputDlg::OutputDlg( CWnd* pParent )
    : CDialog( IDD_OUTPUT_DIALOG, pParent )
{
}

void OutputDlg::RunScriptCmd( const std::string& cmd )
{
    _cmd = cmd;
}

void OutputDlg::DoDataExchange( CDataExchange* pDX )
{
    CDialog::DoDataExchange( pDX );
    DDX_Control( pDX, IDC_EDIT2, outedit );
}

BOOL OutputDlg::OnInitDialog()
{
    CDialog::OnInitDialog();

    std::cerr << "Run: " << _cmd << std::endl;
    CRedirect* redirect = new CRedirect( _cmd.c_str(), &outedit );
    redirect->Run();
    //     redirect->Stop();
    delete redirect;

    return TRUE;
}

